import { LayerSpecification } from 'mapbox-gl';
import { BaseLayer, IBaseLayerParams } from './BaseLayer';

export class LineLayer extends BaseLayer {
  layout: LayerSpecification['layout'];
  paint: LayerSpecification['paint'];

  constructor(cfg: IBaseLayerParams, options?: Partial<LayerSpecification>) {
    super(cfg);
    if (options) {
      this.layout = options.layout;
      this.paint = options.paint;
    }
  }
  addToMap(): string {
    const layerOption: LayerSpecification = {
      id: this.layerId,
      source: this.sourceId,
      type: 'line',
      layout: this.layout,
      paint: this.paint,
    } as LayerSpecification;
    this.map.addLayer(layerOption);
    return this.layerId;
  }
}
